package com.study.project.config.exception;

/**
 * @author yangjie
 * 
 * @see BaseException
 * @date 2024/4/13-17:12
 */

public abstract class BaseException extends RuntimeException {
    private ErrorCode errorCode;

    public BaseException(ErrorCode errorCode) {
        super(errorCode.getMsg());
        this.errorCode = errorCode;
    }

    public BaseException(ErrorCode errorCode, Throwable e) {
        super(errorCode.getMsg(), e);
        this.errorCode = errorCode;
    }

    public BaseException(String errCode, String errMessage) {
        super(errMessage);
        this.errorCode = new ErrorCode.Default(errCode, errMessage);
    }

    public BaseException(String errCode, String errMessage, Throwable e) {
        super(errMessage, e);
        this.errorCode = new ErrorCode.Default(errCode, errMessage);
    }

    public void setErrorCode(final ErrorCode errorCode) {
        this.errorCode = errorCode;
    }

    public ErrorCode getErrorCode() {
        return this.errorCode;
    }
}
